#!/usr/bin/env node

const http=require('http'),
      url=require('url'),
      qs=require('querystring'),
      log=console.log;

http.createServer((req,res)=>{
  log('HTTP request URL:',req.url);

  const path=url.parse('http://wangding:123@www.baidu.com:8080/a/b/c?age=20&gender=M#/d/e/f');
  log('href:',path.href);//服务器端输出
  log('protocol:',path.protocol);
  log('auth:',path.auth);
  log('hostname:', path.hostname);
  log('port:', path.port);
  log('host', path.host);
  log('pathname:', path.pathname);
  log('search:', path.search);
  log('query:', path.query);
  log('hash:', path.hash);

  log('URL parse:', path.pathname.split('/'));
  log('QueryString parse:', qs.parse(path.query));

  res.end('ok!');//浏览器

}).listen(8080);









